package com.lzx.article.controller.web;

import com.lzx.article.entity.Browse;
import com.lzx.article.service.BrowseService;
import com.lzx.common.utils.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 程序员星星
 * @date 2023/2/4
 * @Description
 */
@RestController
@RequestMapping("/article/browse/web")
public class WebBrowseController {
    @Resource
    private BrowseService browseService;

    //通过用户id获取用户浏览记录(提供给用户服务)
    @GetMapping("/getArticleBrowseListToUser/{userId}")
    public List<Browse> getArticleBrowseListToUser(@PathVariable Long userId) {
        return browseService.getArticleBrowseListToUser(userId);
    }

    //通过用户id获取用户浏览记录
    @GetMapping("/getBrowseArticle/{userId}")
    public R getBrowseArticle(@PathVariable Long userId) {
        return browseService.getBrowseArticle(userId);
    }

    //保存用户浏览文章记录
    @PostMapping("/saveUserBrowse")
    public R saveUserBrowse(@RequestBody Browse browse) {
        return browseService.saveUserBrowse(browse);
    }
}
